//
//  WalletLocalData.h
//  MyWallet
//
//  Created by 小肥羊 on 15/7/20.
//  Copyright (c) 2015年 小肥羊. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDatabase.h"

#define DATABASE_PATH [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]stringByAppendingString:@"/WalletLocalData.db"]


/*! @brief 时间类型 */
typedef NS_ENUM(NSUInteger, DataDateType){
    DataDateTypeUnlimited   = 0,    /**< 无限制 */
    DataDateTypeDay         = 1,    /**< 日 */
    DataDateTypeMonth       = 2,    /**< 月 */
    DataDateTypeYear        = 3     /**< 年 */
};


@class WalletLocalData;
@protocol WalletLocalDataDelegate <NSObject>
@required
- (void)upWalletLocalData:(WalletLocalData *)localData Message:(NSString *)message;
@end


#pragma mark - 数据库
@interface WalletLocalData : NSObject

@property (nonatomic,strong) FMDatabase *db;
@property (nonatomic, retain) id <WalletLocalDataDelegate> delegate;

+ (WalletLocalData *)sharedManager;

+ (BOOL)openDB;
+ (BOOL)closeDB;


- (BOOL)addRecord:(NSDate *)recordDtate MoneyFrom:(NSString *)moneyFrom CheckoutType:(BOOL)checkoutType Money:(float)money MoneyFor:(NSString *)moneyFor Remarks:(NSString *)remarks;
- (BOOL)deleteRecord:(NSDate *)recordDtate;
- (BOOL)modifyRecord:(NSDate *)recordDate WithNewDate:(NSDate *)newDate MoneyFrom:(NSString *)moneyFrom CheckoutType:(BOOL)checkoutType Money:(float)money MoneyFor:(NSString *)moneyFor Remarks:(NSString *)remarks;

- (NSMutableArray *)recordArrayWithCount:(NSInteger)count MoneyFrom:(NSString *)moneyFrom;
- (NSMutableArray *)recordArrayWithDate:(NSDate *)day DataDateType:(DataDateType)dataDatetype;
- (NSMutableArray *)statisticsArrayWithDate:(NSDate *)day DataDateType:(DataDateType)dataDatetype;
- (NSMutableDictionary *)incomeAndPayWithDate:(NSDate *)day DataDateType:(DataDateType)dataDatetype;
- (NSMutableArray *)rtatisticsIncomeWithDate:(NSDate *)day DataDateType:(DataDateType)dataDatetype;
- (NSMutableArray *)rtatisticsPayWithDate:(NSDate *)day DataDateType:(DataDateType)dataDatetype;

@end
